In this video we learn how to use the methods and unique and largest and smallest for complete data
frame.
So first of all let's import pandas and we work with the Titanic data set and we will have a look at
the first five rows.
And the last five rows and four pandas serious.
That is the method unique and let's try out if that's also the method unique for a complete data frame
and we get here an error message.
So data frame object has no attributes unique so no panacea is the unique method actually returns say
umpire Ray with all unique value.
So let's try this for The Age column
so we give we get to the unique values for the age column.
However the end unique method also works for a complete data frame and let's try this out here.
And obviously for each column here we get the amount of unique values in the column.
For example as far survived we have 1 0 0 0.
So we have two unique values for passenger class.
We have three unique values.
So Class 1 2 and 3 4 6 we have 2 unique values.
Male and female and so on
and let's have a tech here with the shift tab so we have further parameters axis and drop and a so by
default we drop all missing values but we can change this here
and there I can see in the columns that we have missing values the number of unique values increased
by 1 so by the missing value by the end a value.
And now you can see here that we have for each column the unique values but we can also decide here
that we want to have for each row the unique values by putting your X's equals 1
and in our case of a third the Titanic said I said that's not too meaningful here in row 1 we have 8
unique values so let's check this so we have 1 2 3 4 5 we already had 0 6 7 and 8 including the missing
value will we have 8 unique values.
All right and again we can either include or exclude the missing values here.
Okay so now let's try the method and largest which we also have for pandas serious and let's try to
apply this also for a complete data frame and that's press shift tap here and largest that returns the
first and Rose ordered by columns in the descending order.
So we have to pass here and which stands for example for five rows or four ten rows.
And we have to define the columns by which you want to order a data frame so for example we want to
have the five passengers who paid the largest fare or the largest ticket price.
So let's try this out here and here we have peasants on number 2 5 8.
And uh she paid actually five hundred and twelve dollars a pound and then we have passengers six hundred
seventy nine.
And he also paid five hundred and twelve and the peasants are paid.
The fifth largest ticket price is passenger number eighty eight.
And he paid two hundred and sixty three dollars or pounds and he would actually get the same result
with the software use so we could sort our data frame by the fare column in a descending manner and
then get to the first five rows and this method.
So that's the same here and that's also the end smallest method.
It also works with the complete data frame and with the end smallest method we could filter actually
the five fare youngest passengers on board.
So let's try this so and here we have the five youngest passengers so we have passenger number 800 and
the three And he's only open 40 years old.
And and the fifth the youngest passengers passenger numbers 78.
And he is 0 point eight three years old and we can also change end to one so we can only select the
youngest passenger here.
And as you can see here we get here still a data frame.
So we have a data frame with one row so passenger number 8 0 3.
And before we also learned that we can filter out a specific row with the method idea X-Men so here
is the age column we get the index label for the youngest passenger and then we filled out the row of
the youngest peasant service then the log operator.
And here we do not get a data frame but we get to hear a panda series so on the left we have the columns
and on the right the values and we have a set and smallest we still get a data frame here with only
one row and the values here.
All right.
So now we are finished with this video and I hope to see you in the next one by.